<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta charset="utf-8"/>
    <title>驴妈妈流立方</title>
    <meta name="description" content="overview &amp; stats"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
    <!-- bootstrap & fontawesome -->
    <link rel="stylesheet" href="${rc.contextPath}/assets/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="${rc.contextPath}/assets/font-awesome/4.5.0/css/font-awesome.min.css"/>
    <!-- page specific plugin styles -->
    <link rel="stylesheet" href="${rc.contextPath}/assets/css/daterangepicker.min.css"/>
    <!-- text fonts -->
    <link rel="stylesheet" href="${rc.contextPath}/assets/css/fonts.googleapis.com.css"/>
    <!-- ace styles -->
    <link rel="stylesheet" href="${rc.contextPath}/assets/css/ace.min.css" class="ace-main-stylesheet"
          id="main-ace-style"/>
    <link rel="stylesheet" href="${rc.contextPath}/assets/css/ace-skins.min.css"/>
    <link rel="stylesheet" href="${rc.contextPath}/assets/css/ace-rtl.min.css"/>
    <link rel="stylesheet" href="${rc.contextPath}/assets/css/jquery.gritter.min.css"/>
    <!-- ace settings handler -->
    <script src="${rc.contextPath}/assets/js/ace-extra.min.js"></script>
</head>

<body class="skin-2" style="background-color: #FFF;">
<div class="page-content">
    <div class="page-header">
        <h1>
            <#if pushConfigurationNew?? && pushConfigurationNew.id??>
                编辑配置
                <#else>
                    新建配置
            </#if>
        </h1>

    </div>
    <div class="row">
        <div class="col-xs-12">
            <form id="pushConditionForm" class="form-horizontal" role="form"
                  action="${rc.contextPath}/pushConfiguration/save" method="POST">
                <#if pushConfigurationNew?? && pushConfigurationNew.id??>
                    <input type="hidden" id="id" name="id" value="${pushConfigurationNew.id}">
                </#if>
                <div class="form-group"><label class="col-sm-3 control-label no-padding-right" for="parameterName">
                    <strong class="text-danger">
                        <front color="red">*</front>
                    </strong>参数名称 ： </label>
                    <div class="col-sm-8" id="divValue">
                        <#if pushConfigurationNew?? && pushConfigurationNew.parameterName??>
                            <input type="text" id="parameterName" name="parameterName"
                                   value="${pushConfigurationNew.parameterName}" disabled="true"
                                   class="col-xs-10 col-sm-5">
                            <#else>
                                <input type="text" id="parameterName" name="parameterName"
                                       value="${pushConfigurationNew.parameterName}" class="col-xs-10 col-sm-5">
                                <#list strList as isParameterName>
                                    <input type="hidden" id="isParameterName" name="isParameterName"
                                           value="${isParameterName}" class="col-xs-10 col-sm-5">
                                </#list>
                        </#if>
                    </div>
                </div>
                <div class="form-group"><label class="col-sm-3 control-label no-padding-right" for="parameterValues">
                    <strong class="text-danger">
                        <front color="red">*</front>
                    </strong>参数值 ： </label>
                    <div class="col-sm-8">
                        <input type="text" id="parameterValues" name="parameterValues"
                               value="${pushConfigurationNew.parameterValues}" class="col-xs-10 col-sm-5">
                    </div>
                </div>
                <div class="form-group"><label class="col-sm-3 control-label no-padding-right" for="state">
                    <strong class="text-danger">
                        <front color="red">*</front>
                    </strong>状态 ： </label>&nbsp;&nbsp;
                    <select data-placeholder="" class="chosen-select" tabindex="2" name="state" id="state"
                            style="width:85px">
                        <#list flagTypeList as state>
                            <option value=${state.value} <#if pushConfigurationNew.state == state.value>selected</#if>>${state.showName}</option>
                        </#list>
                    </select>
                </div>
                <div class="form-group"><label class="col-sm-3 control-label no-padding-right" for="remarks">
                    <strong class="text-danger">
                        <front color="red"></front>
                    </strong>备注 ： </label>
                    <div class="col-sm-8">
                        <input type="text" id="remarks" name="remarks" value="${pushConfigurationNew.remarks}"
                               class="col-xs-10 col-sm-5">
                    </div>
                </div>
                <div class="clearfix form-actions">
                    <div class="col-md-offset-4 col-md-8">
                        <button id="submitBtn" class="btn btn-info" type="button">
                            <i class="ace-icon fa fa-check bigger-110"></i>
                            保存
                        </button>
                        <button class="btn btn-info" type="button"
                                onclick="skip('${rc.contextPath}/pushConfiguration/pushConfigurationManagement')"
                                style="margin-left:10px;">
                            <i class="ace-icon fa fa-undo bigger-110"></i>
                            取消
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="${rc.contextPath}/assets/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
    if ('ontouchstart' in document.documentElement) document.write("<script src='${rc.contextPath}/assets/js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>
<script src="${rc.contextPath}/assets/js/bootstrap.min.js"></script>

<!-- page specific plugin scripts -->
<script src="${rc.contextPath}/assets/js/jquery-ui.min.js"></script>
<script src="${rc.contextPath}/assets/js/jquery.ui.touch-punch.min.js"></script>
<script src="${rc.contextPath}/assets/js/jquery.gritter.min.js"></script>

<!-- ace scripts -->
<script src="${rc.contextPath}/assets/js/ace-elements.min.js"></script>
<script src="${rc.contextPath}/assets/js/ace.min.js"></script>
<!-- user scripts -->
<script src="${rc.contextPath}/assets/js/user/base.js"></script>
<script type="text/javascript">
    $('#submitBtn').on('click', function () {

        var parameterName = $("#parameterName").val();
        var parameterValues = $("#parameterValues").val()
        var state = $("#state").val();
        var remarks = $("#remarks").val();
        var name = document.getElementsByName("isParameterName");

        for (var i = 0; i < name.length; i++) {
            if (name[i].value == parameterName) {
                showMsg("配置参数名称已存在,请重新输入！");
                return;
            }
        }

        if (isEmpty(parameterName)) {
            $("#parameterName").focus();
            showMsg("参数名称不能为空！");
        } else if (isEmpty(parameterValues)) {
            $("#parameterValues").focus();
            showMsg("参数值不能为空！");
        } else if (isEmpty(state)) {
            $("#state").focus();
            showMsg("状态不能为空！");
        } else {
            $("#pushConditionForm").submit();
            showMsg("添加成功!");
        }
    });
</script>
</body>
</html>